package com.longlong.controller.adminApi;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.longlong.entity.RegistrationCompetition;
import com.longlong.mapper.RegistrationCompetitionMapper;
import com.longlong.vo.PaginationVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(value = "后台赛程增删改查接口")
@RequestMapping("/competition")
public class competition {

    @Autowired
    private RegistrationCompetitionMapper registrationCompetitionMapper;

    /**
     * 增加赛事
     * @param registrationCompetition
     * @return
     */
    @PostMapping("/competitionInsert")
    private Integer competitionInsert(@RequestBody RegistrationCompetition registrationCompetition){
        return registrationCompetitionMapper.insert(registrationCompetition);
    }

    /**
     * 更新赛事
     * @param registrationCompetition
     * @return
     */
    @PostMapping("/competitionUpdate")
    private Integer competitionUpdate(@RequestBody RegistrationCompetition registrationCompetition){
        return registrationCompetitionMapper.updateById(registrationCompetition);
    }


    /**
     * 分页查询赛事
     * @param paginationVo
     * @return
     */
    @PostMapping("/competitionSelect")
    private Object competitionSelect(@RequestBody PaginationVo paginationVo){
        Page<RegistrationCompetition> page = new Page<>(paginationVo.getPage(),paginationVo.getSize());
        return registrationCompetitionMapper.selectPage(page,null);
    }



}
